package com.xx.xiawan.net;

/**
 * Created by Administrator on 2017-08-23.
 */

import com.dg.acb.utils.NBResponse;

@SuppressWarnings("serial")
public class RequestException extends Exception{
    private final ErrorCode mErrorCode;

    public RequestException(Throwable cause) {
        super(cause);
        mErrorCode = ErrorCode.UNKNOWN_ERROR;
    }

    public RequestException(NBResponse response) {
        super(response.getMessage());
        mErrorCode = ErrorCode.codeOf(response.getCode());
    }

    public RequestException(int code, String errorMessage) {
        super(errorMessage);
        mErrorCode = ErrorCode.codeOf(code);
    }

    public RequestException(ErrorCode error) {
        super(error.getMessage(null));
        mErrorCode = error;
    }

    public ErrorCode getErrorCode() {
        return mErrorCode;
    }
}

